﻿-----------------------------------------------------------------------------------------
-- User defined type
-----------------------------------------------------------------------------------------
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblFileTransferData]') AND type in (N'U'))
	DROP TABLE [dbo].[tblFileTransferData]

--- create a test table
CREATE TABLE tblFileTransferData ( ID INT NOT NULL, Forename VARCHAR(80), Surname VARCHAR(80) NOT NULL, dtCreated DATETIME)

--- create some test data
INSERT INTO tblFileTransferData VALUES ( 1, 'Grahame' ,'Horner' , GETDATE())
INSERT INTO tblFileTransferData VALUES ( 2, 'Collette' ,'Horner' , GETDATE())
INSERT INTO tblFileTransferData VALUES ( 3, 'Ethan' ,'Horner' , GETDATE())
INSERT INTO tblFileTransferData VALUES ( 4, 'John' ,'Horner' , GETDATE())
INSERT INTO tblFileTransferData VALUES ( 5, 'Moura' ,'Horner' , GETDATE())
 
-----------------------------------------------------------------------------------------
-- User defined type
-----------------------------------------------------------------------------------------

--- try upload without SSL
EXEC dbo.UploadTable 'ftp://PS-DEV-001-HOST/FTP-UPLOAD.CSV','HornerG','ftp12345!',false,'tblFileTransferData',1

--- try upload with SSL
EXEC dbo.UploadTable 'ftp://PS-DEV-001-HOST/FTPS-UPLOAD.CSV','HornerG','ftp12345!',true,'tblFileTransferData',1